<template>
  <div>
    <comRNav title="身份验证" />
    <van-form @submit="onSubmit">
      <van-field v-model="password" type="password" name="新密码" label="新密码" placeholder="新密码"
        :rules="[{ required: true, message: '请填写密码' }]" />
      <van-field v-model="threepassword" type="password" name="确认密码" label="确认密码" placeholder="请确认密码"
        :rules="[{ required: true, message: '请填写密码' }]" />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">
          提交
        </van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
import comRNav from "../components/comRNav";
import { Toast } from "vant";
import { userUpdate } from "../utils/login.js";
export default {
  name: "ChangePasswor",
  data() {
    return {
      password: "",
      threepassword: ""
    };
  },
  methods: {
    onSubmit(values) {
      if (this.threepassword != this.password) {
        Toast.success("俩次密码不一样");
        return false;
      }
      userUpdate({
        uid: localStorage.getItem("uid"),
        pass: this.password
      }).then(res => {
        Toast.success("修改成功");
        this.$router.push("/accountManage");
      });
    }
  },

  components: {
    comRNav
  }
};
</script>

<style lang="scss" scoped>
::v-deep .van-button {
  background-color: #fe0000;
  border: none;
}
</style>